<?php 

	class Video {
		
		public function __construct() {
		}

		public static function embedVideo($url,$width,$height){
 
   			if(preg_match("#http://(.*)\.youtube\.com/watch\?v=(.*)(&(.*))?#", $url, $matches)){
     			echo '<center>
           			<object width="'.$width.'" height="'.$height.'">
               			<param name="movie" value="http://www.youtube.com/v/'.$matches[2].'&hl=pt-br&fs=1"></param>
               			<param name="allowFullScreen" value="true"></param>
               			<param name="allowscriptaccess" value="always"></param>
               			<embed src="http://www.youtube.com/v/'.$matches[2].'&hl=pt-br&fs=1" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="'.$width.'" height="'.$height.'"></embed>
            		</object></center>
            	';
   			}elseif(preg_match("#http://www\.metacafe\.com/watch/(([^/].*)/([^/].*))/?#", $url, $matches)){
      			echo '<center><embed flashVars="playerVars=showStats=no|autoPlay=no|videoTitle="  src="http://www.metacafe.com/fplayer/'.$matches[1].'.swf" width="'.$width.'" height="'.$height.'" wmode="transparent" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash"></embed></center>';
   			}	
		}
 
		public static function youtubeImage($url,$tipo='src') {
   			$img = '';
 
   			if(preg_match("#http://(.*)\.youtube\.com/watch\?v=(.*)(&(.*))?#", $url, $matches)){
      			if(isset($matches[2]) && $matches[2]!=''){
         			$img = 'http://s2.ytimg.com/vi/'.$matches[2].'/default.jpg';
      			}
   			}
 
   			return $tipo=='src' ? $img : '<img src="'.$img.'" />';
		}

	}

?>